package books.borrowing;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import books.borrowing.bo.ISubscriberBo;
import books.borrowing.entity.SubscriberEntity;

public class AppSpring {
	
	private static ApplicationContext _appContext;
	private static ISubscriberBo _serviceSubscriber;

	public static void main(String[] args) throws Exception {
		
		_appContext = 
	    		new ClassPathXmlApplicationContext("spring/config/BeanLocations.xml");
		
		_serviceSubscriber = (ISubscriberBo) _appContext.getBean("subscriberBo");

		System.out.println("Test des fonctionnalités applicatives....");

		// GESTION DES UTILISATEURS
		// /////////////////////////

		SubscriberEntity _subscriber = new SubscriberEntity();
		_subscriber.setLogin("dmarie");
		_subscriber.setName("marie");
		_subscriber.setForename("dupont");
		_subscriber.setPassword("mypassword");

		try {
			_serviceSubscriber.save(_subscriber);
			System.out.println("Inscription réussie !");
		} catch (Exception e) {
			System.out.println(e.getMessage());
			e.printStackTrace();
		}

	}
}
